package org.liveboardgames.agricola.business.updater;

import java.util.List;

import org.liveboardgames.agricola.domain.Change;
import org.liveboardgames.agricola.domain.common.Peep;
import org.liveboardgames.agricola.domain.player.Player;
import org.liveboardgames.agricola.domain.player.Score;
import org.liveboardgames.agricola.model.enums.ChangesEnum;

public class PlayerUpdater extends AbstractUpdater {

  private Player player;

  /** game can be null, if not needed for a payment for now */
  public PlayerUpdater(Player player, List<Change> changes) {
    super(changes);
    this.player = player;
  }

  public void addPeep(Peep peep) {
    player.getPeeps().add(peep);
    Change change = new Change(ChangesEnum.PLAYER_NEW_PEEP + player.getId(), peep);
    addChange(change);
  }

  public void updateScore(Score score) {
    player.setScore(score);
    Change change = new Change(ChangesEnum.PLAYER_SCORE + player.getId(), score);
    addChange(change);
  }

}
